//
//  FileManager.m
//  智云网校
//
//  Created by Damon on 2017/6/19.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "FileManagerUtil.h"

//讲义
static NSString *const FILE_PATH_Outline            = @"OutlineD";
//欢拓云
static NSString *const FILE_PATH_Talkfun            = @"TalkfunD";
//CC
static NSString *const FILE_PATH_CCPlayer           = @"CCPlayerD";
//申论批改
static NSString *const FILE_PATH_SLPG               = @"SLPGD";

@implementation FileManagerUtil


+ (void) createDirectoryDownloadFolder{
    [FileManagerUtil createDirectoryAtOutlineDownloadFolder];
    [FileManagerUtil createDirectoryAtTalkfunDownloadFolder];
    [FileManagerUtil createDirectoryAtCCPlayerDownloadFolder];
}
+ (BOOL)createDirectoryAtOutlineDownloadFolder{
    return [FileManagerUtil createDirectoryAtPath:FILE_PATH_Outline];
}
+ (BOOL)createDirectoryAtTalkfunDownloadFolder{
    return [FileManagerUtil createDirectoryAtPath:FILE_PATH_Talkfun];
}
+ (BOOL)createDirectoryAtCCPlayerDownloadFolder{
    return [FileManagerUtil createDirectoryAtPath:FILE_PATH_CCPlayer];
}
+ (BOOL)createDirectoryAtSLPGDownloadFolder{
    return [FileManagerUtil createDirectoryAtPath:FILE_PATH_SLPG];
}
+ (BOOL)createDirectoryAtPath:(NSString *)fileName{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *downloadURL = [fileManager URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
    downloadURL = [downloadURL URLByAppendingPathComponent:fileName];
    return [fileManager createDirectoryAtPath:downloadURL.path withIntermediateDirectories:YES attributes:nil error:nil];
}
+ (NSURL *)getDirectoryAtOutline{
    return [FileManagerUtil getDirectory:FILE_PATH_Outline];
}
+ (NSURL *)getDirectoryAtTalkfun{
    return [FileManagerUtil getDirectory:FILE_PATH_Talkfun];
}
+ (NSURL *)getDirectoryAtCCPlayer{
    return [FileManagerUtil getDirectory:FILE_PATH_CCPlayer];
}
+ (NSURL *)getDirectoryAtSLPG{
    return [FileManagerUtil getDirectory:FILE_PATH_SLPG];
}
+ (NSURL *)getDirectory:(NSString *)fileName{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *downloadURL = [fileManager URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
    downloadURL = [downloadURL URLByAppendingPathComponent:fileName];
    [fileManager createDirectoryAtPath:downloadURL.path withIntermediateDirectories:YES attributes:nil error:nil];
    return downloadURL;
}

@end
